#-------------------------------------------------------------

# paths
SRC_DIR=../src

# project options
TARGET=test-laggard

CC=gcc
LD=gcc
RM=rm -f

REVISION="\"$(shell svn info .. |grep "Last Changed Rev" |cut -d' ' -f4)\""
CCFLAGS=-Wall -MMD -MP -std=gnu99
CCFLAGS+=-DSVN_REVISION=$(REVISION)
LDFLAGS=

DEBUG=YES
RELEASE=NO
PROFILE=NO

#-------------------------------------------------------------

ifneq (,$(findstring MINGW,$(shell uname -s)))
  MINGW=YES
else
  MINGW=NO
endif

SRCS=$(notdir $(shell ls *.c))
SRCS+=$(notdir $(shell ls $(SRC_DIR)/*.c))

VPATH=$(SRC_DIR)
INCLUDES=-I$(SRC_DIR)
LIBS=

OBJS=${SRCS:.c=.o}

ifeq (YES,$(DEBUG))
  CCFLAGS+=-g
  LDFLAGS+=-g
endif

ifeq (YES,$(RELEASE))
  CCFLAGS+=-O3 -DNDEBUG -march=core2
endif

ifeq (YES,$(PROFILE))
  CXXFLAGS+=-pg
  LDFLAGS+=-pg
endif 

ifeq (YES,$(MINGW))
  IVL_EXT_LIB_DIR=$(IVLLIB_DIR)/mswindows
  INCLUDES+=-I$(IVL_EXT_LIB_DIR)/include
  LIBS=
endif

#-------------------------------------------------------------

.PHONY: all
all: $(TARGET)

$(TARGET): $(OBJS)
	$(LD) $(LDFLAGS) $(OBJS)  $(LIBS) -o $@

%.o:%.c
	$(CC) $(CCFLAGS) $(INCLUDES) -c $<

.PHONY clean:
clean:
	$(RM) *.d *.o $(TARGET) core gmon.out

-include ${SRCS:.c=.d}
